<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 编写函数 `camelize(str)`
        // 将诸如“ my - short - string” 之类的由短划线分隔的单词变成骆驼式的“ myShortString”。
        // 即： 删除所有短横线， 并将短横线后的每一个单词的首字母变为大写。
        function camelize(str) {
            var arr2 = [];
            var arr1 = str.split('-');
            // return arr1;
            // return arr1;
            // for (var i = 0; i < arr1.length; i++) {
            //     var f = arr1[i].substr(0, 1);
            //     arr2.push(f.toUpperCase() + arr1[i].substr(1));
            // }
            // return arr2;
            // return arr2.join('');
            // if (arr1.length % 2 == 0) {
            arr2.push(arr1[0])
            for (var i = 1; i < arr1.length; i++) {
                var f = arr1[i].substr(0, 1).toUpperCase();
                arr2.push(f + arr1[i].substr(1));
            }
            return arr2.join('');
        }
        var str1 = camelize("background-color"); // 'backgroundColor';
        var str2 = camelize("-aebkit-transition"); // 'WebkitTransition';
        // var str3 = camelize("webkittransition"); // 'WebkitTransition';
        var str3 = camelize("-cebkit-transi-tion");
        var str4 = camelize("--debkit-transi-tion");
        var str5 = camelize("---e-bk-it-transi-tion");
        var str5 = camelize("---fbk-it-transi-tion");
        var str6 = ("backgroundcolor");

        console.log(str1);
        console.log(str2);
        console.log(str3);
        console.log(str4);
        console.log(str5);
        console.log(str6);
    </script>
</body>

</html>